package com.learn.lombok.delegate;

import com.learn.lombok.delegate.model.DelegateData;
import lombok.Getter;
import lombok.experimental.Delegate;

import java.util.ArrayList;
import java.util.Collection;

@Getter
public class DelegateEntity {

    @Delegate(
            // 只包装 指定接口内的方法
            types = SimpleCollection.class
    )
    private final Collection<String> collection = new ArrayList<>();

    @Delegate(
            // 排除 指定接口内的方法，其他方法全部包装
            excludes = ExcludesDelegateData.class
    )
    private final DelegateData data = new DelegateData();

    private interface SimpleCollection {
        boolean add(String item);

        boolean remove(Object item);
    }

    private interface ExcludesDelegateData {
        void setName(String name);
    }
}
